using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Data;
using System.Windows;
using System.Globalization;

namespace Yorrick.FlickrMetadataSynchr.Flickr
{
   /// <summary>
   /// Converter for <see cref="Visibility"/> to <see cref="bool"/> values for Flickr Pro status.
   /// </summary>
   [ValueConversion(typeof(int), typeof(Visibility))]
   public class ProVisibilityConverter : IValueConverter
   {
      /// <summary>
      /// Converts from Flickr Pro status to a visibility value.
      /// </summary>
      /// <param name="value">The Flickr Pro status value to convert.</param>
      /// <param name="targetType">Not used.</param>
      /// <param name="parameter">Not used.</param>
      /// <param name="culture">Not used.</param>
      /// <returns></returns>
      public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
      {
         bool isPro = (bool)value;

         return (isPro ? Visibility.Visible : Visibility.Hidden);
      }

      /// <summary>
      /// Converts from a visibility value to a Flickr Pro status.
      /// </summary>
      /// <param name="value">The visibility value to convert.</param>
      /// <param name="targetType">Not used.</param>
      /// <param name="parameter">Not used.</param>
      /// <param name="culture">Not used.</param>
      /// <returns></returns>
      public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
      {
         Visibility visibility = (Visibility)value;

         return (visibility == Visibility.Visible ? true : false);
      }
   }
}
